package com.k.jdbc.utils;

import java.util.List;
import java.util.Map;

/**
 * @author langjw
 */
public class SqlExecutorTest {
    public static void main(String[] args) {
        test2();

    }
    private static void test2(){
        SqlExecutor sqlExecutor = SqlExecutor.builder()
                .setDbType(DatabaseTypeEnum.POSTGRESQL)
                .setDbHost("127.0.0.1")
                .setDbPort(5432)
                .setDbInstance("smpnew")
                .setDbUsername("postgres")
                .setDbPassword("123456")
                .build();
        List<Map<String,Object>> list = sqlExecutor.selectList("select * from smp_t_function t where system_code='SYS_CODE_SMP'  and t.language_code='zh-CN' and guid='00b8051b-ecc0-45b6-8310-f4c8ca97dc51'");
        System.out.println(list);
    }

    private void test1(){
        SqlExecutor sqlExecutor = SqlExecutor.builder()
                .setDbType(DatabaseTypeEnum.POSTGRESQL)
                .setDbHost("localhost")
                .setDbPort(5432)
                .setDbInstance("dsssz12")
                .setDbUsername("postgres")
                .setDbPassword("123456")
                .build();
        // reset
        sqlExecutor.setHost("10.161.64.87");
        sqlExecutor.setDatabaseInstance("dws_12");

        List<Map<String,Object>> list = sqlExecutor.selectList("select * from user_account");
        for(Map<String,Object> itm:list){
            for(Map.Entry<String,Object> entry:itm.entrySet()){
                String key = entry.getKey();
                Object value= entry.getValue();
                String typeName = value.getClass().getTypeName();
                System.out.print(key+":"+value+"("+typeName+")  ");
            }
            System.out.println();
        }
    }
}
